Source files and additional resources related to this repository can be accessed on the Harvard Dataverse at https://doi.org/10.7910/DVN/YHEOOK.
 
Stereo digital elevation models (DEMs) were generated for this repository using [Ames Stereo Pipeline 3.0.0](https://github.com/NeoGeographyToolkit/StereoPipeline) and [USGS ISIS 3.5.1](https://github.com/USGS-Astrogeology/ISIS3). These programs require a Unix-based (Mac or Linux) command line environment.
 
## Generating individual CTX stereo DEMs
The only strict requirement for generating DEMs from stereo pairs is that the two source images must have some amount of spatial overlap. Best results are typically obtained when lighting conditions between the two images are similar, and neither image is obscured by dust or other artifacts. Similar lighting conditions are most likely for images obtained during similar mission subphases, indicated by the first letter and two digits in the product ID or filename (e.g. “P01” and “P02”), but this is not a hard and fast rule.
 
Stereo pairs for this repository were selected and downloaded manually by browsing for overlapping images on the (Mars Orbital Data Explorer)[https://ode.rsl.wustl.edu/mars/index.aspx]. A file structure consisting of individual subdirectories for each stereo pair was created that contained all the files and scripts necessary for running a completely automated end-to-end stereo DEM generation routine. The repository scripts assume that both ISIS and ASP commands are already included in the `$PATH` environment variable.
 
A typical stereo pair directory will initially include two experimental data record (EDR) IMG files downloaded from the Planetary Data System (PDS), along with the Slurm batch script `run_asp` and shell script `preprocess.sh`. The stereo DEMs in the repository were generated by running the batch script on Brown University’s [Oscar](https://docs.ccv.brown.edu/oscar) computing cluster.
 
In order, the script `preprocess.sh` first converts the raw IMG files to image cubes that are readable by ISIS. The cubes are then calibrated and map-projected to prepare them for stereo correlation.
 
The ASP command `stereo` takes the argument `-s <path>/stereo.map` for the config file of the same name located in the home directory. This file is available from [Mayer (2018)](https://github.com/USGS-Astrogeology/asp_scripts/blob/master/config/ctx_map_disp_filter_7_13_0.13.stereo) and uses an optimized median filter size of 7, texture smoothing size of 13, and texture smoothing scale of 0.13. The `stereo` command takes the map-projected image cubes and performs stereo correlation to generate an initial point cloud.
 
The ASP commands `point2dem` and `dem_geoid` convert the point cloud to a digital elevation model (DEM) and correct the elevation values in the DEM to the Mars reference spheroid (R = 3,396,190 m), respectively. `point2dem` takes the argument `--tr 20` to specify the desired resolution of the final DEM of 20 m/pix. This value was chosen to make the files easier to import into the DERT visualization software, which requires images to have relative dimensions in powers of 2; thus, the DEMs are 1/4 the resolution of the original CTX GeoTIFF files.
 
Each stereo DEM was manually inspected for data quality and assigned a score from 1-3, with 3 being the highest quality (Table 1).
 
The map-projected, geoid-adjusted DEM files are included in the repository with filenames ending in `map_DEM-adj.tif`.
 
## Mosaicking and filling gaps with MOLA
 
Overlapping DEMs of specific features of interest were mosaicked together with a background tile of the [MOLA global topography mosaic](https://astrogeology.usgs.gov/search/details/Mars/GlobalSurveyor/MOLA/Mars_MGS_MOLA_DEM_mosaic_global_463m/cub). Background tiles were generated using the Minimum Bounding Geometry tool in ArcMap to encompass the constituent CTX DEM footprints.
 
The shell script `pc_align_d.sh` registers each CTX DEM to be mosaicked against the MOLA tile, assuming all the files are contained in a single directory, and then mosaics them together. A list of the post-alignment DEMs in mosaic order (files ending in `trans_source-DEM.tif`) must be provided by the user in `mosaic_order.lis`.

The script uses an initial transform to obtain the correct vertical offset between each CTX DEM and the MOLA tile, then uses this offset to perform a second manual alignment on the original DEM source files. The ASP command `dem_mosaic` must then be run twice, first to mosaic the MOLA-registered DEMs together, and then the combined CTX DEM mosaic with the MOLA tile. Because the alignment of the original DEMs with their respective CTX source images is typically more accurate, the MOLA tile is shifted horizontally in the final mosaic to more closely align with the mosaicked CTX DEMs. In the second `dem_mosaic` step, the argument `--priority-blending-length 20` is used to specify that gaps in the CTX DEM mosaic should be filled with the lower-resolution MOLA tile and blended over a distance of 20 pixels, which is avoided in the first step to maintain as much of the original high-resolution data as possible.
 
The final blended mosaics are included in the repository with filenames ending in `mola_bl20_20-tile-0.tif`.